/**
 * 
 */
package com.rangers.auth.sample.jpa.entity;

import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;

import com.rangers.auth.base.details.BriefMenu;
import com.rangers.auth.base.details.MenuTypeEnum;
import com.rangers.auth.sample.jpa.convert.SetMenuConverter;

import lombok.Data;

@Data
@Entity
@Table(name = "tb_menu")
public class Menu implements BriefMenu<Menu,Long> {
	@Id
	@GeneratedValue
	private Long id;

	private Long parentId;

	@Column(columnDefinition="blob", nullable=true)
	@Convert(converter=SetMenuConverter.class)
	private Set<Menu> childrens;// 子级菜单

	@NotEmpty(message = "菜单名称不能为空")
	@Length(max = 32, message = "菜单名称必须在[32]位以内")
	private String name;// 菜单名

	@NotNull(message = "菜单类型不能为空")
	@Enumerated(EnumType.ORDINAL)
	private MenuTypeEnum type;// 菜单类型

	private String link;// 链接path

	private String permissions;// 数据权限
	
}
